package com.cyj.user.dao;

import com.cyj.user.entity.User;

import java.util.List;

import com.cyj.user.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    // 插入用户
    @Insert("INSERT INTO UserTable (uName, uPwd, uType, uMemo) VALUES (#{uName}, #{uPwd}, #{uType}, #{uMemo})")
    int insertUser(User user);

    // 根据编号查询用户
    @Select("SELECT * FROM UserTable WHERE uCode = #{id}")
    User selectUserById(@Param("id") int id);

    // 查询所有用户
    @Select("SELECT * FROM UserTable")
    List<User> selectAllUsers();

    // 更新用户信息
    @Update("UPDATE UserTable SET uName = #{uName}, uPwd = #{uPwd}, uType = #{uType}, uMemo = #{uMemo} WHERE uCode = #{uCode}")
    int updateUser(User user);

    // 删除用户
    @Delete("DELETE FROM UserTable WHERE uCode = #{id}")
    int deleteUserById(@Param("id") int id);

    //用户和密码查询
    @Select("SELECT * FROM UserTable WHERE uName = #{uName} AND uPwd = #{uPwd}")
    User selectUserByUsernameAndPassword(@Param("uName") String uName, @Param("uPwd") String uPwd);
}
